<?php

/**
 * Description of Application_Model_Fields_Recurso_Chamadas
 *
 * @author Jean Brito
 */
class Application_Model_Fields_Recurso_Chamadas extends Application_Model_Fields_Abstract {

	public function getSqlWhere($value=''){
		return "(".$this->getSqlFieldName()." like '%".$value."%')";
	}

	public function getSqlSet(array $value=array()){
		$result='';
		foreach($value as $item){
			if(isset($item['chamada_id']))
				$result.=$item['chamada_id'].",";
		}
		return "'".substr($result,0,strlen($result)-1)."'";
	}
	public function getSqlValue($row=''){
		if(!isset($row[$this->_name]))return array();
		$value=trim(str_replace("\t","",str_replace("\n","",$row[$this->_name])));
		if($value=='')return array();
		$vetor=explode(",",$value);
		$result=array();
		foreach($vetor as $item){
			$result[]=array('recurso_id'=>trim(str_replace("\t","",str_replace("\n","",$row['nome']))),'chamada_id'=>$item);
		}
		return $result;
	}

}
